<?php 

/**
* 首页控制器
*/
class IndexController extends Controller
{
	public function Index()
	{	
		$color = ['alert-success','alert-info','alert-warning','alert-danger'];
		$res = M('msg');
		$sql = "select * from msg order by id desc";
		$msgs = $res->query($sql);
		//var_dump($msgs);

		//操作模型[具体操作数据库某张表的方法]
		// $msgs = D('Msg')->Top10();
		// var_dump($msgs);

		//分配数据 传第一个参数为键名,第二个为值
		$this->assgin('color',$color);
		$this->assgin('msgs',$msgs);
		////$this->display();不传参数调用默认视图,反之调用指定参数的视图
    	$this->display();
	}
	
	public function Lists()
	{
		echo "首页控制器的lists方法";

	}

	public function Edit()
	{
		$edit = M('msg')->where('id='.$_GET['id'])->find();
		$edit = current($edit);
		var_dump($edit);
		$this->assgin('edit',$edit);
		$this->display();
	}
}
















 ?>